/***************************************
 * 说明：本文件主要列举第6章文中课后习题
 * *************************************/
#include "test.h"
/*************************************
 * 习题6.3：在例题6.3的基础上做一些修改
 * *********************************/
void exercise3()
{
    Circle2* ci = new Circle2(1,2,3);
    Point* point = new Circle2(1,2,3);
    ci->show_area();
    point->show_area();
}

/*************************************
 * 习题6.4：写一个程序，定义抽象基类Shape，
 * 由它派生Circle/Rectangle/Triangle
 * 用一个函数show_area输出三证的面积值
 * *********************************/
void exercisr4()
{
    Shape* shape;
    shape = new Circle(1);
    shape->show_area();

    shape = new Rectangle(1,2);
    shape->show_area();

    shape = new Triangle(1,2,3);
    shape->show_area();
}
/*******************************************
 * 习题6.5：写一个程序，定义抽象基类Shape，
 * 由它派生Circle/Rectangle/Triangle
 * 用基类指针数组，使得它的每个元素指向一个派生类
 * ******************************************/
void exercise5()
{
    Shape* shape[4];
    shape[0] = new Circle(1);
    shape[1] = new Rectangle(1,2);
    shape[2] = new Triangle(1,2,3);
    shape[3]= new Square(2);
    for (int i = 0; i<4; i++) {
        shape[i]->show_area();
    }
}

/*******************************************
 * 习题6.6：写一个程序
 * ******************************************/
void exercise6()
{}

int main()
{
    exercise5();
    return 0;
}